﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8" />
    <title>批量处理</title>
    <link href="../Scripts/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <link href="../Scripts/bootstrap/css/font-awesome.css" rel="stylesheet" />
    <link href="../Scripts/bootstrap/bootstrap-table/src/bootstrap-table.css" rel="stylesheet" type="text/css" />
    <link href="../Scripts/bootstrap/css/style.min.css" rel="stylesheet" type="text/css" media="all" />

    <!--jquery-->
    <script src="../Scripts/jquery-1.11.0.min.js" type="text/javascript"></script>
    <script src="../Scripts/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
    <link href="../Scripts/layui/layui/css/modules/layer/default/layer.css" rel="stylesheet" />
    <script src="../Scripts/layui/layui/lay/modules/layer.js"></script>

    <!--bootstrap-table-->
    <script src="../Scripts/bootstrap/bootstrap-table/src/bootstrap-table.js" type="text/javascript"></script>
    <script src="../Scripts/bootstrap/bootstrap-table/src/locale/bootstrap-table-zh-CN.js" type="text/javascript"></script>
    <script src="../Scripts/bootstrap/bootstrap-paginator/js/bootstrap-paginator.js" type="text/javascript"></script>
    <script src="../Scripts/bootstrap/BootstrapUIDialog.js" type="text/javascript"></script>

    <!--公共JS-->
    <script src="../Scripts/QueryString.js" type="text/javascript"></script>
    <script src="../Scripts/config.js" type="text/javascript"></script>
    <script src="Gener.js" type="text/javascript"></script>
    <script language="JavaScript" src="JScript.js" type="text/javascript"></script>
    <script src="../Comm/JS/Calendar/WdatePicker.js" type="text/javascript"></script>
    <link href="../Comm/JS/Calendar/skin/WdatePicker.css" rel="stylesheet" type="text/css" />
    <script src="../Admin/CCFlowEnum.js" type="text/javascript"></script>
    <!--serach页面JS开发接口-->
    <script src="../../DataUser/JSLibData/SearchSelf.js" type="text/javascript"></script>

    <base target="_self" />
    <style type="text/css">
        .Wdate {
            border: 1px solid #e5e6e7;
            height: 28px;
        }

        .fixed-table-container thead th .th-inner {
            padding: 8px;
            line-height: 24px;
            vertical-align: top;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap; /**background-color: #eaf2ff;**/
            width: 100%;
        }

        .fixed-table-header {
            background-color: #f2f2f2;
        }

        td {
            word-break: keep-all; /* 不换行 */
            white-space: nowrap; /* 不换行 */
            overflow: hidden; /* 内容超出宽度时隐藏超出部分的内容 */
            text-overflow: ellipsis; /* 当对象内文本溢出时显示省略标记(...) ；需与overflow:hidden;一起使用*/
            -o-text-overflow: ellipsis;
            -icab-text-overflow: ellipsis;
            -khtml-text-overflow: ellipsis;
            -moz-text-overflow: ellipsis;
            -webkit-text-overflow: ellipsis;
        }

        body {
            margin: 0px;
        }

        .panel-header, .panel-body {
            border-width: 1px;
            border-top: 0px;
            border-left: 0px;
            border-right: 0px;
        }

        .table {
            table-layout: fixed;
        }

        table > td {
            width: 100%;
        }

        .pagination {
            margin: 8px 0;
            display: block;
            font-size: 13px;
        }

            .pagination .controls {
                float: left;
                border: 0;
                padding: 7px 0 0 15px;
                color: #777;
            }
    </style>

    </style>
    <script language="javascript" type="text/javascript">

        //定义公共个变量.
        var webUser = new WebUser();

        var ensName = GetQueryString("EnsName");


        //页面设置信息
        var cfg = new Entity("BP.Sys.EnCfg");
        cfg.No = ensName;
        cfg.RetrieveFromDBSources();

        //页面字体大小
        var fontSize = cfg.GetPara("FontSize");
        if (fontSize == null || fontSize == undefined || fontSize == 0)
            fontSize = 13;


        //当前用户页面信息.
        var ur = new Entity("BP.Sys.UserRegedit");
        ur.MyPK = webUser.No + "_" + ensName + "_SearchAttrs";
        ur.RetrieveFromDBSources();
        var count = ur.GetPara("RecCount");
        var mapBase;
        var pageIdx = this.GetQueryString("PageIdx");
        var pageSize = 10;

        //页面启动函数.
        $(function () {

            if (webUser.No == undefined) {
                alert('登录信息丢失，请重新登录。');
                return;
            }
            if (ensName == null || ensName == undefined) {
                $("#Msg").html("必要的参数EnsName没有传入.");
                return;
            }
            $("#Msg").html("<img src=../Img/loading.gif />&nbsp;正在加载,请稍后......");

            $("#dialogExpFile").hide();
            //初始化工具栏.
            InitToolbar();

            if (pageIdx == null || pageIdx == "" || pageIdx == undefined)
                pageIdx = 1;
            //执行查询.
            BindTable();
            var pageCount = parseInt((count) / 10) + 1;
            //分页设计
            Paginator(pageCount, pageIdx);

            //批处理事件的获取
            BatchMethod();

            $("#Msg").html("");
            $("td").on("mouseover", function () {
                if (this.offsetWidth < this.scrollWidth) {
                    var that = this;
                    var text = $(this).text();
                    layer.tips(text, that, {
                        tips: 1,
                        time: 0
                    });
                }
            });
            $("td").on("mouseout", function () {
                layer.closeAll();
            });
            $("#BatchHtm").css("font-size", fontSize + "px");
        });
        function InitToolbar() {
            //创建处理器.
            var handler = new HttpHandler("BP.WF.HttpHandler.WF_Comm");
            handler.AddUrlData();  //增加参数.
            //获得map基本信息.
            mapBase = handler.DoMethodReturnJSON("Search_MapBaseInfo");

            // $("#Title").html(mapBase.EnDesc);
            document.title = mapBase.EnDesc;

            //获得查询信息，包含了查询数据表.
            var data = handler.DoMethodReturnJSON("Search_SearchAttrs");

            var barCount = 0; //记录查询条件，超过五个就换行
            var IsTableShow = false;
            //绑定外键枚举查询条件.
            var attrs = data["Attrs"];
            if (attrs.length > 0) {
                for (var i = 0; i < attrs.length; i++) {
                    if (attrs[i].Width >= 1000) {
                        IsTableShow = true;
                        break;
                    }

                }
            }
            var html = "";
            if (IsTableShow || 1 == 1) {
                showBarTable(attrs, data);
                return;
            }

            if (mapBase.IsShowSearchKey == "1") {
                var keyLabel = cfg.GetPara("KeyLabel");
                if (keyLabel == null || keyLabel == undefined || keyLabel == "")
                    keyLabel = "关键字";
                html += "<label  style='text-align: right; margin-top:5px;margin-left:5px;' for='TB_Key'>" + keyLabel + ":&nbsp;&nbsp</label>"
                html += "<input style='width:140px;' type=text id='TB_Key' name='TB_Key' value='" + ur.SearchKey + "' class='form-control' />";
                barCount += 1;
            }

            if (mapBase.DTSearchWay != "0") {
                barCount += 2;
                html += "<label style='text-align: right; margin-top:5px;padding-left:20px;'>" + mapBase.DTSearchLable + ":&nbsp;&nbsp</label>";

                if (mapBase.DTSearchWay == "1") {
                    html += "<input type=text id='TB_DTFrom' name='TB_DTFrom' value='" + ur.DTFrom + "'  onfocus=\"WdatePicker({dateFmt:'yyyy-MM-dd'})\" style='width:120px;' class='form-control' />";
                    html += "&nbsp;&nbsp;<label>到</label>&nbsp;&nbsp<input type=text id='TB_DTTo' name='TB_DTTo' value='" + ur.DTTo + "' onfocus=\"WdatePicker({dateFmt:'yyyy-MM-dd'})\" style='width:140px;' class='form-control' />";
                } else {
                    html += "<input type=text id='TB_DTFrom' name='TB_DTFrom' value='" + ur.DTFrom + "'  onfocus=\"WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'});\" style='width:140px;' class='form-control' />";
                    html += "&nbsp;&nbsp;<label>到</label>&nbsp;&nbsp<input type=text id='TB_DTTo' name='TB_DTTo' value='" + ur.DTTo + "' onfocus=\"WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'});\"  style='width:120px;' class='form-control' />";
                }
            }

            $("#toolbar").append(html); //设置基础信息.

            //格式为: @WFSta=0@FK_Dept=02
            var json = AtParaToJson(ur.Vals);

            for (var i = 0; i < attrs.length; i++) {
                var attr = attrs[i];
                var str = "";

                str += "<label style='text-align: right; margin-top:5px;margin-left:5px;' for='DDL_" + attr.Field + "'>" + attr.Name + ":</label>";

                str += "<select class='form-control' style='margin-top:5px;width:" + attr.Width + "px' name='DDL_" + attr.Field + "' ID='DDL_" + attr.Field + "'>" + InitDDLOperation(data, attr, "all") + "</select>";
                str = $(str);

                barCount += 1;

                $("#toolbar").append(str); //设置基础信息.
            }

            html = "";
            //为查询外键赋值.
            for (var i = 0; i < attrs.length; i++) {
                var attr = attrs[i];
                var selectVal = json[attr.Field];

                if (selectVal == undefined || selectVal == "")
                    selectVal = "all";

                //判断是否有级联关系
                var myPK = "ActiveDDL_" + ensName + "_" + attr.Field;
                var mapExt = new Entity("BP.Sys.MapExt");
                mapExt.SetPKVal(myPK);
                var isExist = mapExt.RetrieveFromDBSources();
                //处理级联关系
                if (isExist == 1) {
                    var ddlPerant = $("#DDL_" + mapExt.AttrOfOper);
                    var ddlChild = $("#DDL_" + mapExt.AttrsOfActive);
                    if (ddlPerant != null && ddlChild != null) {
                        ddlPerant.attr("onchange", "DDLRelation(this.value,\'" + "DDL_" + mapExt.AttrsOfActive + "\', \'" + mapExt.MyPK + "\',\'" + ddlPerant.val() + "\')");

                    }
                }

                $("#DDL_" + attr.Field).val(selectVal);
            }

            html += '<a href="#"class="btn btn-primary btn-sm" style="margin-left:20px" id="search_btn" onclick="Search()">查询</a>  ';
            var btnLab1 = cfg.GetPara("BtnLab1");
            var btnLab2 = cfg.GetPara("BtnLab2");
            if (btnLab1 != null && btnLab1 != undefined && btnLab1 != "")
                html += "&nbsp;<a href='#'class='btn btn-default btn-sm'   onclick='executeFunction(\"" + cfg.GetPara("BtnJS1") + "\",\"" + btnLab1 + "\")'>" + btnLab1 + "</a>";

            if (btnLab2 != null && btnLab2 != undefined && btnLab2 != "")
                html += "&nbsp;<a href='#'class='btn btn-default btn-sm'   onclick='executeFunction(\"" + cfg.GetPara("BtnJS2") + "\",\"" + btnLab2 + "\")'>" + btnLab2 + "</a>";

            if (mapBase.IsInsert.toString().toLowerCase() == "true") {
                html += '<a href="#" class="btn btn-default btn-sm" id="new_btn" onclick="New()">新建</a>  ';
            }
            html += '<a href="#" class="btn btn-default btn-sm" id="exp_btn" onclick="Exp()">导出</a>  ';

            if (mapBase.IsImp.toString().toLowerCase() == "true")
                html += '<a href="#" class="btn btn-default btn-sm" id="imp_btn" onclick="Imp()">导入</a>';

            if (new WebUser().No == "admin")
                html += '<a href="#" class="btn btn-default btn-sm" id="setting_btn" onclick="Setting()">设置</a>';




            $("#toolbar").append(html);

        }

        function showBarTable(attrs, data) {
            var html = "";

            if (attrs.length == 0)
                html += "<table style='width:30%;' >";

            if (attrs.length == 1)
                html += "<table style='width:50%;' >";

            if (attrs.length > 1)
                html += "<table style='width:100%;' >";


            html += "<tr>";
            if (mapBase.IsShowSearchKey == "1") {
                var keyLabel = cfg.GetPara("KeyLabel");
                if (keyLabel == null || keyLabel == undefined || keyLabel == "")
                    keyLabel = "关键字";
                html += "<td align='right'><label  style='text-align: right; margin-top:5px;margin-left:5px;' for='TB_Key'>" + keyLabel + ":</label></td>";
                html += "<td align='left'><input style='width:100%;' type=text id='TB_Key' name='TB_Key' value='" + ur.SearchKey + "' class='form-control' /></td>";
            }
            if (mapBase.DTSearchWay != "0") {
                html += "<td align='right'><label style='text-align: right; margin-top:5px;padding-left:20px;'>" + mapBase.DTSearchLable + ":</label></td>";

                if (mapBase.DTSearchWay == "1") {
                    html += "<td align='left'><input type=text id='TB_DTFrom' name='TB_DTFrom' value='" + ur.DTFrom + "'  onfocus=\"WdatePicker({dateFmt:'yyyy-MM-dd'})\" style='width:120px;' class='form-control Wdate' /></td>";
                    html += "<td align='left'>&nbsp;<label>到</label>&nbsp;&nbsp<input type=text id='TB_DTTo' name='TB_DTTo' value='" + ur.DTTo + "' onfocus=\"WdatePicker({dateFmt:'yyyy-MM-dd'})\" style='width:120px;' class='form-control Wdate' /></td>";
                } else {
                    html += "<td align='left'><input type=text id='TB_DTFrom' name='TB_DTFrom' value='" + ur.DTFrom + "'  onfocus=\"WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'});\" style='width:160px;' class='form-control Wdate' /></td>";
                    html += "<td align='left'>&nbsp;<label>到</label>&nbsp;&nbsp<input type=text id='TB_DTTo' name='TB_DTTo' value='" + ur.DTTo + "' onfocus=\"WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'});\"  style='width:160px;' class='form-control Wdate' /></td>";
                }
            }


            //格式为: @WFSta=0@FK_Dept=02
            var json = AtParaToJson(ur.Vals);

            for (var i = 0; i < attrs.length; i++) {
                var attr = attrs[i];
                var W = attr.Width;
                if (attr.Width >= 1000) {
                    html += "</tr>";
                    html += "<tr>";
                    W = 130;
                }

                html += "<td align='right'><label style='text-align: right; margin-top:5px;margin-left:5px;' for='DDL_" + attr.Field + "'>" + attr.Name + ":</label></td>";
                html += "<td align='left'><select class='form-control' style='margin-top:5px;width:100%;' name='DDL_" + attr.Field + "' ID='DDL_" + attr.Field + "'>" + InitDDLOperation(data, attr, "all") + "</select></td>";
            }

            //增加按钮.
            html += '<td align="left" colspan=2 ><a href="#"class="btn btn-primary btn-sm" style="margin-left:20px" id="search_btn" onclick="Search()">查询</a>  ';

            var btnLab1 = cfg.GetPara("BtnLab1");
            var btnLab2 = cfg.GetPara("BtnLab2");
            if (btnLab1 != null && btnLab1 != undefined && btnLab1 != "")
                html += "&nbsp;<a href='#'class='btn btn-default btn-sm'  onclick='executeFunction(\"" + cfg.GetPara("BtnJS1") + "\",\"" + btnLab1 + "\")'>" + btnLab1 + "</a>";

            if (btnLab2 != null && btnLab2 != undefined && btnLab2 != "")
                html += "&nbsp;<a href='#'class='btn btn-default btn-sm'   onclick='executeFunction(\"" + cfg.GetPara("BtnJS2") + "\",\"" + btnLab2 + "\")'>" + btnLab2 + "</a>";

            if (mapBase.IsInsert.toString().toLowerCase() == "true")
                html += '&nbsp;<a href="#" class="btn btn-default btn-sm" id="new_btn" onclick="New()">新建</a>';

            html += '&nbsp;<a href="#" class="btn btn-default btn-sm" id="exp_btn" onclick="Exp()">导出</a>';

            if (mapBase.IsImp.toString().toLowerCase() == "true")
                html += '&nbsp;<a href="#" class="btn btn-default btn-sm" id="exp_btn" onclick="Imp()">导入</a> ';
            if (new WebUser().No == "admin")
                html += '&nbsp;<a href="#" class="btn btn-default btn-sm" id="setting_btn" onclick="Setting()">设置</a>';

            html += "</td></tr>";

            html += "</table>";

            $("#toolbar").append(html);

            //为查询外键赋值.
            for (var i = 0; i < attrs.length; i++) {
                var attr = attrs[i];
                var selectVal = json[attr.Field];

                if (selectVal == undefined || selectVal == "")
                    selectVal = "all";
                //判断是否有级联关系
                var myPK = "ActiveDDL_" + ensName + "_" + attr.Field;
                var mapExt = new Entity("BP.Sys.MapExt");
                mapExt.SetPKVal(myPK);
                var isExist = mapExt.RetrieveFromDBSources();
                //处理级联关系
                if (isExist == 1) {
                    var ddlPerant = $("#DDL_" + mapExt.AttrOfOper);
                    var ddlChild = $("#DDL_" + mapExt.AttrsOfActive);
                    if (ddlPerant != null && ddlChild != null) {
                        ddlPerant.attr("onchange", "DDLRelation(this.value,\'" + "DDL_" + mapExt.AttrsOfActive + "\', \'" + mapExt.MyPK + "\',\'" + ddlPerant.val() + "\')");

                    }
                }

                $("#DDL_" + attr.Field).val(selectVal);
            }
        }


        //初始化下拉列表框的OPERATION
        function InitDDLOperation(frmData, mapAttr, defVal) {

            var operations = "";
            operations += "<option value='all' >全部</option>";

            var ens = frmData[mapAttr.Field];


            //ens为null时则为枚举类型
            if (ens == null) {
                ens = [{ 'IntKey': 0, 'Lab': '否' }, { 'IntKey': 1, 'Lab': '是' }];
            }

            for (var i = 0; i < ens.length; i++) {

                var en = ens[i];

                if (en.No == undefined)
                    operations += "<option value='" + en.IntKey + "'>" + en.Lab + "</option>";
                else
                    operations += "<option value='" + en.No + "'>" + en.Name + "</option>";
            }
            return operations;
        }

        //执行查询.
        function Search(pageIdx) {

            //保存查询条件.
            var ensName = GetQueryString("EnsName");
            var ur = new Entity("BP.Sys.UserRegedit");
            ur.MyPK = webUser.No + "_" + ensName + "_SearchAttrs";
            ur.FK_Emp = webUser.No;

            if ($("#TB_Key") != null && $("#TB_Key").val() != "")
                ur.SearchKey = $("#TB_Key").val();
            else
                ur.SearchKey = "";

            //设置查询时间.
            if ($("#TB_DTFrom").length == 1)
                ur.DTFrom = $("#TB_DTFrom").val();

            if ($("#TB_DTTo").length == 1)
                ur.DTTo = $("#TB_DTTo").val();

            //获得外键的查询条件,存储里面去.
            var str = "";
            $("select[name^='DDL_']").each(function () {
                var id = $(this).attr("id");
                id = id.replace("DDL_", "");
                str += "@" + id + "=" + $(this).val();
            });

            ur.FK_Emp = webUser.No;
            ur.CfgKey = "SearchAttrs";
            ur.Vals = str;
            ur.FK_MapData = ensName;
            var i = ur.Save();

            var data = SearchData();
            $("#bsTable").bootstrapTable("load", data["DT"]);

            if (pageIdx == null || pageIdx == "" || pageIdx == undefined)
                pageIdx = 1;

            var pageCount = parseInt((count) / 10) + 1;
            //分页设计
            Paginator(pageCount, pageIdx);
        }

        //获取查询数据
        function SearchData() {
            //创建处理器.
            var handler = new HttpHandler("BP.WF.HttpHandler.WF_Comm");
            handler.AddPara("DoWhat", "Batch");
            handler.AddPara("EnsName", GetQueryString("EnsName"));
            handler.AddPara("PageIdx", pageIdx);
            handler.AddPara("PageSize", pageSize);
            //查询集合
            var data = handler.DoMethodReturnString("Search_SearchIt");
            if (data.indexOf('err@') == 0) {
                alert(data);
                return;
            }

            data = JSON.parse(data);
            //当前用户页面信息.
            var ur = new Entity("BP.Sys.UserRegedit");
            ur.MyPK = webUser.No + "_" + ensName + "_SearchAttrs";
            ur.RetrieveFromDBSources();

            count = ur.GetPara("RecCount");
            return data;
        }

        //生成Easyui DataGrid列表页面..
        function BindTable() {
            //获取页面的高度
            var H = document.body.clientHeight;
            var tableH = H - $("#toolbar").outerHeight() - $("#page-nav").outerHeight() - 60;

            var mapdata = SearchData();

            var attrs = mapdata["Attrs"];

            if (attrs == undefined) {
                alert('没有取得属性.');
                return;
            }

            var keyOfEn = "";

            var columns = new Array();
            columns.push({
                field: "ck",
                fixed: false,
                checkbox: true,
                width: 60,
                singleSelect: false,

            });
            for (var i = 0; i < attrs.length; i++) {
                var attr = attrs[i];

                if (attr.UIVisible == 0
                    || attr.KeyOfEn == "OID"
                    || attr.KeyOfEn == "WorkID"
                    || attr.KeyOfEn == "NodeID"
                    || attr.KeyOfEn == "MyNum"
                    || attr.KeyOfEn == "MyPK") {
                    keyOfEn = attr.KeyOfEn
                    continue;
                }


                var field = attr.KeyOfEn;
                var title = attr.Name;
                if (attr.UIContralType == 1)
                    field = field + "Text";
                if (attr.UIContralType == 2)
                    columns.push({
                        field: field,
                        title: title,
                        fixed: false,
                        formatter: function (value, row, index) {
                            if (value == "0") return "否";
                            if (value == "1") return "是";

                        }
                    });
                else {
                    var width = attr.Width;
                    if (width == null || width == "" || width == undefined)
                        width = 180;
                    columns.push({
                        field: field,
                        title: title,
                        width: width,
                        fixed: false,
                    });
                }
            }


            var data = mapdata["DT"];
            $('#bsTable').bootstrapTable({
                data: data,
                columns: [columns],
                fitColumns: false,
                fit: true,
                rownumbers: true,
                striped: true,
                height: tableH,
                singleSelect: false,
                checkOnSelect: false,
                selectOnCheck: false,
                onDblClickRow: function (row, $element) {
                    var pkval = row["No"];
                    var objectID = "No";
                    if (pkval == undefined) {
                        pkval = row["OID"];
                        objectID = "OID";
                    }
                    if (pkval == undefined) {
                        pkval = row["MyPK"];
                        objectID = "MyPK";
                    }
                    if (pkval == undefined) {
                        pkval = row["WorkID"];
                        objectID = "WorkID";
                    }
                    if (pkval == undefined) {
                        pkval = row["NodeID"];
                        objectID = "NodeID";
                    }
                    var paras = "&" + objectID + "=" + pkval;
                    for (var i = 0; i < attrs.length; i++) {
                        var attr = attrs[i];
                        if (attr.UIContralType == 1)
                            paras += "&" + attr.KeyOfEn + "=" + row[attr.KeyOfEn];
                    }

                    OpenEn(pkval, paras);
                }

            });
        }

        //分页功能
        function Paginator(pageCount, currentPage) {
            var pageCount = pageCount; //取到pageCount的值(把返回数据转成object类型)
            var options = {
                bootstrapMajorVersion: 3, //版本
                currentPage: currentPage, //当前页数
                totalPages: pageCount, //总页数
                shouldShowPage: true, //是否显示该按钮
                itemTexts: function (type, page, current) {
                    switch (type) {
                        case "first":
                            return "首页";
                        case "prev":
                            return "上一页";
                        case "next":
                            return "下一页";
                        case "last":
                            return "末页";
                        case "page":
                            return page;
                    }
                }, //点击事件，用于通过Ajax来刷新整个list列表
                onPageClicked: function (event, originalEvent, type, page) {
                    pageIdx = page;
                    SearchData(page);
                }
            };
            $('#useroption').bootstrapPaginator(options);
        }



        //批处理事件的获取
        function BatchMethod() {
            //创建处理器.
            var handler = new HttpHandler("BP.WF.HttpHandler.WF_Comm");
            handler.AddPara("EnsName", GetQueryString("EnsName"));
            //查询集合
            var data = handler.DoMethodReturnString("Refmethod_BatchInt");
            if (data.indexOf('err@') == 0) {
                alert(data);
                return;
            }

            var refMethods = JSON.parse(data);
            if (refMethods.length == 0) return;

            var html = "<table id='Table1' align='left'  border=0 width='100%'>";
            html += "<tr class='TRSum'  border=0>"
            html += "<td>"

            for (var i = 0; i < refMethods.length; i++) {
                var en = refMethods[i];
                html += "<input type='button' class='btn btn-default' value='" + en.Title + "' onclick='operateBatch(\"" + en.RefMethodType + "\",\"" + en.Url + "\",\"" + en.Title + "\",\"" + en.Warning + "\",\"" + en.W + "\",\"" + en.H + "\")'/>";
            }
            $("#refMethod").html(html);
        }

        //点击事件
        function operateBatch(methodType, url, title, warning, width, height) {
            //获取前台页面的复选框的值
            var pkValue = GetChecked();
            if (pkValue == null || pkValue == "") {
                alert("请选择要执行的行");
                return;
            }

            url = url.replace(/PKVal=/g, "PKVal=" + pkValue);

            if (parseInt(methodType) == RefMethodType.Func) {
                if (warning == "null" || warning == "")
                    warning = "您确定要执行吗?";

                else {
                    warning = warning.replace(/,\s+/g, ",");
                    warning = warning.replace(/\s+/g, "\r\n");
                }
                if (confirm("\"" + warning + "\"")) {
                    OpenBootStrapModal(url, "eudlgframe", title, width, height, "icon-property", null, null, null, null, null, 'black');
                }

            } else {
                OpenBootStrapModal(url, "eudlgframe", title, width, height, "icon-property", null, null, null, null, null, 'black');
            }
        }

        //获取选中的行内容
        function GetChecked() {
            var checkedItems = $('#bsTable').bootstrapTable('getSelections');

            var names = "";
            $.each(checkedItems, function (index, item) {
                var pkval = item.No;
                if (pkval == null || pkval == undefined)
                    pkval = item.OID;

                if (pkval == null || pkval == undefined)
                    pkval = item.WorkID;

                if (pkval == null || pkval == undefined)
                    pkval = item.NodeID;

                if (pkval == null || pkval == undefined)
                    pkval = item.MyNum;

                if (pkval == null || pkval == undefined)
                    pkval = item.MyPK;

                names = names + pkval + ",";

            });
            return names.substring(0, names.length - 1);
        }

        //导出EXCEL表
        function Exp() {
            var handler = new HttpHandler("BP.WF.HttpHandler.WF_Comm");
            handler.AddPara("EnsName", GetQueryString("EnsName"));
            //查询集合
            var data = handler.DoMethodReturnString("Search_Exp");
            var url = "";
            if (data.indexOf('err@') == 0) {
                alert(data);
            }

            data = basePath + data;
            window.open(data);
            return;

        }


        //打开明细表
        function OpenEn(pk, paras) {
            //var select_row = $('#bsTable').bootstrapTable('getSelections');
            var ensName = GetQueryString("EnsName");
            var enName = ensName.substring(0, ensName.length - 1);

            var cfg = new Entity("BP.Sys.EnCfg");
            cfg.No = ensName;
            cfg.RetrieveFromDBSources();

            var url = cfg.GetPara("WinOpenUrl");

            if (url == "" || url == undefined) {
                url = "./RefFunc/En.htm?EnName=" + mapBase.EnName + "&PKVal=" + pk;
            }
            else {
                if (url.indexOf('?') == -1)
                    url = url + "?1=1";
                url = url + "&EnsName=" + ensName + "&enName=" + enName + "&PKVal=" + pk + paras;
            }

            var windowW = cfg.GetPara("WinCardW");
            if (windowW == "" || windowW == undefined)
                windowW = 700;

            var windowH = cfg.GetPara("WinCardH");
            if (windowH == "" || windowH == undefined)
                windowH = 500;

            var localUrl = window.location.href;


            OpenBootStrapModal(url, "eudlgframe", mapBase.EnDesc + ' : 详细', windowW, windowH, "icon-property", null, null, null, function () {
                window.location.href = localUrl;
            }, null, 'black');
        }

        function New() {
            OpenEn("");


        }

        //跳转到设置页面
        function Setting() {
            var user = new WebUser();
            var url = "./Sys/SearchSetting.htm?EnsName=" + GetQueryString("EnsName") + "&m=" + Math.random();
            //获取屏幕的长宽
            var W = document.body.clientWidth - 40;
            var H = document.body.clientHeight - 40;
            OpenBootStrapModal(url, "eudlgframe", '设置', W, H, "icon-property", null, null, null, null, null, 'black');
        }


        function executeFunction(jsString, label) {
            jsString = jsString.replace(/~/g, "'");
            if (jsString.indexOf("/") != -1) {
                var W = document.body.clientWidth - 40;
                var H = document.body.clientHeight - 40;
                OpenBootStrapModal(jsString, "eudlgframe", label, W, H, "icon-property", null, null, null, null, null, 'black');
            } else {
                if (jsString.indexOf('(') == -1)
                    eval(jsString + "()");
                else
                    eval(jsString);
            }
        }
    </script>
</head>
<body id="BatchHtm">
 <div class="wrapper wrapper-content animated fadeInRight" style="padding: 0px 10px 0px 10px">
        <div class="ibox-content">
            <div class="row">
                <div class="panel panel-default" style="border: 0px; margin-bottom: 3px">
                    <div id="toolbar" style="width: 100%">
                    </div>
                </div>
            </div>
            <div class="row">
                <table id="bsTable" class="table table-hover" style="word-wrap: break-word; word-break: break-all;">
                </table>
            </div>
            <div class="row">
                 <div id="refMethod"  style="margin-top:5px"></div>
            </div>
        </div>
 </div>
</body>
</html>
